home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / storage / page / part.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  1.0 KB  |  54 lines

  1. /*
  2.  * part.c --
  3.  *    POSTGRES "partition" code.
  4.  */
  5.  
  6. #include "tmp/c.h"
  7.  
  8. #include "storage/block.h"
  9. #include "storage/bufpage.h"    /* XXX for PageSize */
  10. #include "storage/off.h"
  11. #include "storage/part.h"
  12.  
  13. RcsId("$Header: /private/postgres/src/storage/page/RCS/part.c,v 1.6 1991/05/01 02:51:32 cimarron Exp $");
  14.  
  15. /*
  16.  * PagePartitionIsValid is now a macro in part.h -cim 4/27/91
  17.  */
  18.  
  19. PagePartition
  20. CreatePagePartition(blockSize, pageSize)
  21.     BlockSize    blockSize;
  22.     PageSize    pageSize;
  23. {
  24.     Assert(BlockSizeIsValid(blockSize));
  25.     Assert(PageSizeIsValid(pageSize));
  26.  
  27.     if (pageSize > blockSize || blockSize % pageSize != 0) {
  28.         return (InvalidPagePartition);
  29.     }
  30.     {
  31.         Count        numberOfPages = blockSize / pageSize;
  32.         PagePartition    partition = 0;
  33.  
  34.         while (numberOfPages > 1) {
  35.             partition += 1;
  36.             numberOfPages /= 2;
  37.         }
  38.         return (partition);
  39.     }
  40. }
  41.  
  42. Count
  43. PagePartitionGetPagesPerBlock(partition)
  44.     PagePartition    partition;
  45. {
  46.     Count    numberOfPages = 1;
  47.  
  48.     while (partition > 0) {
  49.         numberOfPages *= 2;
  50.         partition -= 1;
  51.     }
  52.     return (numberOfPages);
  53. }
  54.